<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    function add() {
      var sum = 0,
        len = arguments.length;
      for (var i = 0; i < len; i++) {
        sum += arguments[i];
      }
      return sum;
    }

    add();
    add(1);
    add(1, 2);
  </script>
</html>
